//引入请求方法
import {request} from '../../request/index.js';
import regeneratorRuntime from '../../lib/runtime/runtime';

// pages/collect/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs:[
      {
        id:0,
        value:"商品收藏",
        isActive:true,
      },
      {
        id:1,
        value:"品牌收藏",
        isActive:false,
      },
      {
        id:2,
        value:"店铺收藏",
        isActive:false,
      },
      {
        id:3,
        value:"浏览足迹",
        isActive:false
      }
    ],
    collect:[]
  },

  onShow(){
    const collect = wx.getStorageSync("collect")||[];
    this.setData({
      collect
    })
      
  },
  //根据标题选中激活
  ChangeTitleByIndex(index){
    //修改源数组
    let {tabs} = this.data;
    tabs.forEach((v,i) => i===index?v.isActive=true:v.isActive=false);
    //赋值到data中
    this.setData({
      tabs
    })
  },
  //标题 点击事件，从子组件传递过来的
  handleTabsItemChange(e){
    //console.log(e);
    //获取被点击的标题索引
    const {index} = e.detail;
    this.ChangeTitleByIndex(index);
    //重新发送请求
    // this.ChangeTitleByIndex(index+1);
  },
})